import unittest
from parameterized import parameterized
import requests



def josndd():

    login_data1=[
        {
            "13800000002",
            "123456"
            },
        {
            "1380000sasds",
            "123456"
        },{
            "13800000002",
            "1234567"
            }

    ]
    return login_data1
class MyTestCase(unittest.TestCase):

    def setUp(self):
        # 实例化session对象
        self.session = requests.Session()

        self.url_login = "http://ihrm-java.itheima.net/api/sys/login"
        # teardown

    def tearDown(self):
        # 关闭session对象
        self.session.close()
        # 登录成功

    @parameterized.expand(josndd)
    def test_success(self,username,password):
        # 发送验证码请求并断言

        # login_data = {
        #     "username": "13800000002",
        #     "password": "123456",
        #
        # }
        login_data1 = {
            "username": username,
            "password": password
        }

        response = self.session.post(url=self.url_login, data=login_data1)
        print(response.json())
        self.assertEqual(200, response.status_code)

        # 账号不存在

